<?php
class orderformAction extends Action {
    public function index(){
       //建立查询
       global $SystemConest;
       $m=M("orderform");
       $sql="select * from ".$SystemConest[7]."orderform as a left join ".$SystemConest[7]."pay as b on a.orderform3=b.pay1 where a.orderform2=554 order by a.orderform0 desc";
       $rs=fanye($m,$sql,50,2,"");
       $this->assign("rs",$rs["rs"]);
       $this->assign("show",$rs["show"]);
       $this->display();
    }
    
    /**
     * 客栈订单列表
     */
    function innlist(){
    	global $SystemConest;
    	$m=M("orderform");
    	$sql="select *,c.hotel1 as chotel1 from ".$SystemConest[7]."orderform as a 
    	left join ".$SystemConest[7]."pay as b on a.orderform3=b.pay1 left join ".$SystemConest[7]."hotel as c on a.orderform1=c.hotel0

    	where a.orderform2=618 order by a.orderform0 desc";
    	 $rs=fanye($m,$sql,50,2,"");
	     $this->assign("rs",$rs["rs"]);
	     $this->assign("show",$rs["show"]);
	     $this->display();
   	

    }
    
    
    
    
    public function editorder()
    {
    	$id=$_GET["id"];//获取这条订单的id
    	if (!is_numeric($id)) die("请输入正确的参数");
    	global $SystemConest;
    	$mr=M("orderform");

    	$sql="select * from ".$SystemConest[7]."orderform as a left join ".$SystemConest[7]."pay as b on a.orderform3=b.pay1 where a.orderform0=".$id." order by a.orderform0 desc";
    	$rs=$mr->query($sql);
    	if($rs[0]["orderform1"]!="")
		{
			
			$tourmr=A("tour");
			//@todo: 不能跨项目调用
			$trs=$tourmr->getrsone("tour0=".$rs[0]["orderform1"]);
		}
    	$this->assign("rs",$rs[0]);
    	$this->assign("trs",$trs);
    	$this->assign("adminname",$SystemConest[2]);
    	$this->assign("Login",$_SESSION["Login"]);
    	$this->display();
    	require_once RootDir.'/inc/Calendar.php';
    }
    
    
   function hoteleditorder()
    {
    	
    	$id=$_GET["id"];//获取这条订单的id
    	if (!is_numeric($id)) die("请输入正确的参数");
    	global $SystemConest;
    	$mr=M("orderform");

    	$sql="select *,c.hotel1 as chotel1 from ".$SystemConest[7]."orderform as a 
    	left join ".$SystemConest[7]."pay as b on a.orderform3=b.pay1
		left join ".$SystemConest[7]."hotel as c on a.orderform1=c.hotel0
    	where a.orderform0=".$id." order by a.orderform0 desc";
    	$rs=$mr->query($sql);
    	if($rs[0]["orderform1"]!="")
		{
			
			$tourmr=A("hotel");
			//@todo: 不能跨项目调用
			$trs=$tourmr->getrsone("hotel0=".$rs[0]["orderform1"]);
		}
		
    	$this->assign("rs",$rs[0]);
    	$this->assign("trs",$trs);
    	$this->assign("adminname",$SystemConest[2]);
    	$this->assign("Login",$_SESSION["Login"]);
    	$this->display();
    	require_once RootDir.'/inc/Calendar.php';
    }
    
    
    
    function saveisdo()
    {
    	$myt=D("orderform");
		$oid=$_REQUEST["orderform0"];//订单表的id
		
		
		
		if($myt->create())
		{
			$num=$myt->save();
			if($num)
			{
				//dosomething如发邮件
				$issendmail=$_POST["issendmail"];//是否发送邮件标识
				if($issendmail=="1")
				{
					require_once RootDir."/inc/MailClass.php";
					$contenthtml=file_get_contents("http://".$_SERVER['SERVER_NAME']."/sendmail/ReceiveOrder/orderid/".$oid);
					if(sendmymail($_REQUEST["tomail"],"mzl","梦之旅提醒您，您的订单已经授理",$contenthtml));
					{
						$temp=",邮件发送成功";
					}
				}
				alert(__APP__."/editorder/id/".$oid,2,"保存成功".$temp);
				
			}
			else
			{
				alert(__APP__."/orderform/editorder/id/".$oid,2,"保存失败");
			}
		}
    }
    
    /**
     * 保存酒店订单操作
     */
    function hotelsaveisdo()
    {
    	$myt=D("orderform");
		$oid=$_REQUEST["orderform0"];//订单表的id
		
		
		
		if($myt->create())
		{
			$num=$myt->save();
			if($num)
			{
				//dosomething如发邮件
				$issendmail=$_POST["issendmail"];//是否发送邮件标识
				if($issendmail=="1")
				{
					require_once RootDir."/inc/MailClass.php";
					$contenthtml=file_get_contents("http://".$_SERVER['SERVER_NAME']."/sendmail/ReceiveOrder/orderid/".$oid);
					if(sendmymail($_REQUEST["tomail"],"mzl","梦之旅提醒您，您的订单已经授理",$contenthtml));
					{
						$temp=",邮件发送成功";
					}
				}
				alert(__APP__."/orderform/hoteleditorder/id/".$oid,2,"保存成功".$temp);
				
			}
			else
			{
				alert(__APP__."/orderform/hoteleditorder/id/".$oid,2,"保存失败");
			}
		}
    }
    
    
    
    function savekccycontent()
    {
    	$id=$_REQUEST["id"];
    	if(!is_numeric($id)) die("请传入正确的参数");
    	$mr=M("orderform");
    	$contet="{@客内:".$_REQUEST["orderform24kn"]."@}";
    	$contet.="{@客名:".$_REQUEST["orderform24km"]."@}";
    	$contet.="{@客时:".$_REQUEST["orderform24ks"]."@}";
    	
    	$contet.="{@操内:".$_REQUEST["orderform24cn"]."@}";
    	$contet.="{@操名:".$_REQUEST["orderform24cm"]."@}";
    	$contet.="{@操时:".$_REQUEST["orderform24cs"]."@}";
    	
    	$contet.="{@财内:".$_REQUEST["orderform24cain"]."@}";
    	$contet.="{@财名:".$_REQUEST["orderform24caim"]."@}";
    	$contet.="{@财时:".$_REQUEST["orderform24cais"]."@}";
    	
    	$contet.="{@产内:".$_REQUEST["orderform24cann"]."@}";
    	$contet.="{@产名:".$_REQUEST["orderform24canm"]."@}";
    	$contet.="{@产时:".$_REQUEST["orderform24cans"]."@}";
    	
    	if($mr->where('orderform0='.$id)->setField('orderform24',$contet))
    	{
    		alert("orderform_editorder_id_".$id,2,"保存成功");
    	}
    	else
    	{
    		alert("orderform_editorder_id_".$id,2,"保存失败");
    	}
    	
    	
    	
    }
    
}

?>